﻿/*
/*NHibernate映射代码模板
/*吕震修改使用升级版My Generation映射 Oracle
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using Model.Common;


namespace Model
{
	/// <summary>
	///	Modules:论坛模块
	/// </summary>
	[Serializable]
	public partial class Modules : IDataEntity 
	{
		#region 私有成员
			
		private bool keyIsChanged;
		private bool keyIsDeleted;
		private int keyModuleId; 
		private string keyModuleName; 
		private string keyModuleImage; 
		private string keyModuleDescription; 
		private int keyVersion; 		
		
		#endregion
		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public Modules()
		{
			keyModuleId = 0; 
			keyModuleName = null; 
			keyModuleImage = null; 
			keyModuleDescription = null; 
			keyVersion = 0; 
		}
		#endregion
		
		#region  公有属性
			
		
		/// <summary>
		/// ModuleId:模块Id
		/// </summary>		
		public virtual int ModuleId
		{
			get { return keyModuleId; }
			set { IsChanged |= (keyModuleId != value); keyModuleId = value; }
		}
			
		
		/// <summary>
		/// ModuleName:模块名称
		/// </summary>		
		public virtual string ModuleName
		{
			get { return keyModuleName; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("ModuleName:模块名称无效!", value, value.ToString());
				
				IsChanged |= (keyModuleName != value); keyModuleName = value;
			}
		}
			
		
		/// <summary>
		/// ModuleImage:模块图片
		/// </summary>		
		public virtual string ModuleImage
		{
			get { return keyModuleImage; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("ModuleImage:模块图片无效!", value, value.ToString());
				
				IsChanged |= (keyModuleImage != value); keyModuleImage = value;
			}
		}
			
		
		/// <summary>
		/// ModuleDescription:模块描述
		/// </summary>		
		public virtual string ModuleDescription
		{
			get { return keyModuleDescription; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("ModuleDescription:模块描述无效!", value, value.ToString());
				
				IsChanged |= (keyModuleDescription != value); keyModuleDescription = value;
			}
		}
			
		
		/// <summary>
		/// Version:描述
		/// </summary>		
		public virtual int Version
		{
			get { return keyVersion; }
			set { IsChanged |= (keyVersion != value); keyVersion = value; }
		}
			
			
		/// <summary>
		/// 对象是否为新增
		/// </summary>
		public virtual bool IsAdded
		{
			get { return keyModuleId == 0 ? true : false; }
		}
			
		/// <summary>
		/// 对象的值是否被改变
		/// </summary>
		public virtual bool IsChanged
		{
	 		get { return keyIsChanged; }
            set { keyIsChanged = value; }
		}
		
		/// <summary>
		/// 对象是否已经被删除
		/// </summary>
		public virtual bool IsDeleted
		{
			get { return keyIsDeleted; }
		}
		
		#endregion 
		
		#region 公有函数
		
		/// <summary>
		/// 标记对象已删除
		/// </summary>
		public virtual void MarkAsDeleted()
		{
			keyIsDeleted = true;
			keyIsChanged = true;
		}
		
		/// <summary>
		/// 初始化对象标记
		/// </summary>
		public virtual void ResetMark()
		{
			keyIsDeleted = false;
			keyIsChanged = false;
		}
		
		#endregion
		
		#region 重写Equals和HashCode
		/// <summary>
		/// 用唯一值实现Equals
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != GetType() ) ) return false;
			Modules castObj = (Modules)obj; 
			return ( castObj != null ) &&
				(keyModuleId == castObj.ModuleId );
		}
		
		/// <summary>
		/// 用唯一值实现GetHashCode
		/// </summary>
		public override int GetHashCode()
		{
			int hash = 57; 
			hash = 27 * hash * keyModuleId.GetHashCode();
			return hash; 
		}
		#endregion
		
		
	}
}
